<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;

/**
 * 量表下载记录
 */
class RatingScaleDownloadLogModel extends BaseModel
{
    protected $name = 'rating_scale_download_log';

    /**
     * 新增数据验证
     * @return array
     */
    public function addValidate()
    {
        return [
            'unit_id|单位ID'  => 'require',
            'uid|下载人id'  => 'require',
            'cloud_id|云端id'  => 'require',
            'rating_scale_id|量表id'  => 'require',
        ];
    }

    /**
     * 关联云端量表库
     * @return BelongsTo
     */
    public function RatingScaleCloudModel(): BelongsTo
    {
        return $this->belongsTo('RatingScaleCloudModel', 'cloud_id')->bind(['name','cover','download_price']);
    }

    /**
     * 关联单位
     * @return BelongsTo
     */
    public function Unit(): BelongsTo
    {
        return $this->belongsTo('UnitModel', 'unit_id')->bind([
            'unit_name' => 'name',
            'province_name',
            'city_name',
            'area_name'
        ]);
    }
}